package com.futurelight.recipes.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.futurelight.recipes.model.Result;

import java.util.List;

@Dao
public interface RecipesDao {
    @Query("select * from results where type=:type")
    List<EntityResult> getResults(String type);

    @Query("select * from results inner join favorite on results.id = favorite.resultId")
    List<EntityResult> getFavorites();

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insertResult(EntityResult ... result);

    @Insert
    void insertFavorite(EntityFavorite ... favorite);

    @Delete
    void deleteFavorite(EntityFavorite ... favorite);

    @Query("select * from favorite where resultId=:resultId")
    EntityFavorite findFavorite(int resultId);
}
